
{extend name="layout/base"}
{block name="title"}收件箱{/block}
{block name="css"}
<link href="__admin_static__/css/plugins/iCheck/custom.css" rel="stylesheet">
<link href="__admin_static__/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
{/block}
{block name="head_js"}{/block}
{block name="body"}
<style>
    .danger{
        color:#ed5565;
    }
    .read .fa-tag,.fa-phone{
        color: #1ab394;
    }
    .pagination{
        margin: 0;
    }
</style>
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="row">
        <div class="col-sm-12 animated fadeInRight">
            <div class="mail-box-header">

                <form method="post" action="{:url('index')}" class="pull-right mail-search" id="mailForm" target="_self" >
                    <div class="input-group">
                        <input type="text" class="form-control input-sm" name="keyword" {if condition="!empty($input.keyword)"}value="{$input.keyword}"{/if} placeholder="搜索邮件标题">
                        <div class="input-group-btn">
                            <button type="submit" class="btn btn-sm btn-primary">
                                搜索
                            </button>
                        </div>
                    </div>
                </form>
                <h2>
                    收件箱 ({$mail_list|count})
                </h2>
                <div class="mail-tools tooltip-demo m-t-md">
                    <div class="btn-group pull-right">
                        {$mail_page}
                    </div>
                    <button class="btn btn-white btn-sm" data-toggle="tooltip" data-placement="left" title="刷新邮件列表" onclick="javascript:MailAction.refresh();"><i class="fa fa-refresh"></i> 刷新</button>
                    <button class="btn btn-white btn-sm" data-toggle="tooltip" data-placement="top" title="标为已读" onclick="javascript:MailAction.read();"><i class="fa fa-eye"></i>
                    </button>
                    <button class="btn btn-white btn-sm" data-toggle="tooltip" data-placement="top" title="删除邮件"  onclick="javascript:MailAction.del();"><i class="fa fa-trash-o"></i>
                    </button>

                </div>
            </div>
            <div class="mail-box">
                <table class="table table-hover table-mail">
                    <tbody>
                    {foreach name="mail_list" item="mail"}
                    <tr class="{if condition='$mail.is_read == 0'}unread{else}read{/if}">
                        <td class="check-mail">
                            <input type="checkbox" class="i-checks" name="select[]" value="{$mail.id}">
                        </td>
                        <td class="mail-ontact"><a target="_self" href="{:url('detail',['id'=>$mail.id])}">{$mail.title}</a>
                        </td>
                        <td class="mail-subject"><a target="_self" href="{:url('detail',['id'=>$mail.id])}"><i class="fa fa fa-phone"></i> {$mail.phone}</a>
                        </td>
                        <td class="mail-subject"><a target="_self" href="{:url('detail',['id'=>$mail.id])}">{$mail.description}</a>
                        </td>
                        <td class="">
                            {if condition='$mail.is_read == 0'}
                            <i class="fa fa fa-tag danger"></i> 未读
                            {else}
                            <i class="fa fa fa-tag"></i> 已读
                            {/if}
                        </td>
                        <td class="text-right mail-date">{$mail.add_time|date='Y-m-d H:i',###}</td>
                    </tr>
                    {/foreach}
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
<script src="__admin_static__/js/jquery.min.js?v=2.1.4"></script>
<script src="__admin_static__/js/bootstrap.min.js?v=3.3.5"></script>
<script src="__admin_static__/js/content.min.js?v=1.0.0"></script>
<script src="__admin_static__/js/plugins/iCheck/icheck.min.js"></script>
<script src="__admin_static__/js/plugins/sweetalert/sweetalert.min.js"></script>
<script src="__admin_static__/js/base.js"></script>
<script>
    $(document).ready(function(){$(".i-checks").iCheck({checkboxClass:"icheckbox_square-green",radioClass:"iradio_square-green",})});

    var MailAction = {
        //页面刷新
        refresh : function()
        {
            window.location.reload();
        },
        //标记已读
        read : function()
        {
            var idList = MailAction.getCheckVal();
            if(idList.length == 0)
            {
                return;
            }
            Base_warning_location({
                title:'您确定标记为已读吗',
                text:'标记为已读后无法恢复标记未读噢',
                confirmText:'已读',
                location:'{:url("hasRead")}',
                data : {'id':idList}
            });

        },
        //删除邮件
        del : function()
        {
            var idList = MailAction.getCheckVal();
            if(idList.length == 0)
            {
                return;
            }
            Base_warning_location({
                title:'您确定删除邮件吗',
                text:'删除后将无法恢复，请慎重考虑',
                confirmText:'删除',
                location:'{:url("del")}',
                data : {'id':idList}
            });
        },

        getCheckVal :function()
        {
            var idList = [];
            $('input.i-checks').each(function(){
                var target = $(this);
                //如果当前选择框被选中
                if(target.is(':checked'))
                {
                    idList.push(target.val());
                }
            });
            return idList;
        }
    };
</script>
<script type="text/javascript" src="http://tajs.qq.com/stats?sId=9051096" charset="UTF-8"></script>
</body>
{/block}
